// pages/user/orderList/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isLogin:true,//是否登录了 默认否
    active:1,
    list: [{
      date:'2021/08/07',
      show:false,
      foodList:[
        {
          name:'【Q弹爽口】香堤土豆粉香堤土豆粉香堤土豆粉香堤土豆1',
          money:'1.43'
        },
        {
          name:'【Q弹爽口】香堤土豆粉香堤土豆粉香堤土豆粉香堤土豆2',
          money:'1.43'
        },
        {
          name:'【Q弹爽口】香堤土豆粉香堤土豆粉香堤土豆粉香堤土豆3',
          money:'1.43'
        },
        {
          name:'【Q弹爽口】香堤土豆粉香堤土豆粉香堤土豆粉香堤土豆4',
          money:'1.43'
        },
        {
          name:'【Q弹爽口】香堤土豆粉香堤土豆粉香堤土豆粉香堤土豆5',
          money:'1.43'
        }
      ]
    },
    {
      date:'2021/08/07',
      show:false,
      foodList:[
        {
          name:'【Q弹爽口】香堤土豆粉香堤土豆粉香堤土豆粉香堤土豆1',
          money:'1.43'
        },
        {
          name:'【Q弹爽口】香堤土豆粉香堤土豆粉香堤土豆粉香堤土豆2',
          money:'1.43'
        },
        {
          name:'【Q弹爽口】香堤土豆粉香堤土豆粉香堤土豆粉香堤土豆3',
          money:'1.43'
        },
        {
          name:'【Q弹爽口】香堤土豆粉香堤土豆粉香堤土豆粉香堤土豆4',
          money:'1.43'
        },
        {
          name:'【Q弹爽口】香堤土豆粉香堤土豆粉香堤土豆粉香堤土豆5',
          money:'1.43'
        }
      ]
    }
    ],//店铺列表
    pageSize:5,//分页每页显示条数
    pageNum:1,//当前页数
    total:5,//总条数
    activeIdx:2
  },
  changeTab(event){
    //切换tab
    var dataset=event.currentTarget.dataset
    this.setData({
      active:dataset.type
    })
  },
  setShow(event){
    //展开收起
    var dataset=event.currentTarget.dataset
    var list=this.data.list
    if(dataset.show==1){
      list[dataset.index].show=true
    }else{
      list[dataset.index].show=false
    }
    this.setData({
      list
    })
  },
  goPj(){
    //去评价
    wx.navigateTo({
      url: '/pages/youXuan/evaluateAdd/index',
    })
  },
  goLookPj(){
    //查看评价
    wx.navigateTo({
      url: '/pages/youXuan/evaluateDes/index',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      active:options.active
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    console.log('下拉了')
    setTimeout(()=>{
      wx.stopPullDownRefresh()
    },1000)
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    if(this.data.total>this.data.list.length){
      setTimeout(()=>{
        let arr=[{
          date:'2021/08/07',
          show:false,
          foodList:[
            {
              name:'【Q弹爽口】香堤土豆粉香堤土豆粉香堤土豆粉香堤土豆1',
              money:'1.43'
            },
            {
              name:'【Q弹爽口】香堤土豆粉香堤土豆粉香堤土豆粉香堤土豆2',
              money:'1.43'
            },
            {
              name:'【Q弹爽口】香堤土豆粉香堤土豆粉香堤土豆粉香堤土豆3',
              money:'1.43'
            },
            {
              name:'【Q弹爽口】香堤土豆粉香堤土豆粉香堤土豆粉香堤土豆4',
              money:'1.43'
            },
            {
              name:'【Q弹爽口】香堤土豆粉香堤土豆粉香堤土豆粉香堤土豆5',
              money:'1.43'
            }
          ]
        }]
        let data=this.data.list.concat(arr)
        this.setData({
          list:data
        })
      },1000)
    }
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})